package cn.brondfish.icedfish.database.system.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import java.util.List;

import cn.brondfish.icedfish.database.system.entity.SysUserPermission;

@Dao
public interface SysUserPermissionDao {

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    public void insert(List<SysUserPermission> permissions);

    @Query("DELETE FROM sys_user_permission")
    public void delete();

    @Query("SELECT permission FROM sys_user_permission WHERE device = :device")
    public List<String> getPermissions(String device);


    @Query("SELECT count(permission) FROM sys_user_permission WHERE device = :device and permission = :permission")
    public boolean havePermissions(String device,String permission);

}
